package plugin;

import java.util.LinkedList;

import js.java.stspluginlib.PluginClient.ZugFahrplanZeile;

public class DecryptedTimeTable extends LinkedList<DecryptedTimeTableSingle> {
	private static final long serialVersionUID = 1L;
	protected String nextName = "";
	protected String nextAb = "";
	protected String nextNach = "";
	protected String nextVon = "";
	protected long eta = 0;
	private MainUI main;

	DecryptedTimeTable(LinkedList<js.java.stspluginlib.PluginClient.ZugFahrplanZeile> plan, ConnectionManager cManager,
			Train train) {
		this.main = train.getUi().getMainUI();
		for (ZugFahrplanZeile zeile : plan) {
			this.add(new DecryptedTimeTableSingle(this, zeile, cManager));
		}
		long an = this.getFirst().an;
		int verspaetung = train.verspaetung;
		eta = (an / 1000) + (verspaetung * 60);
	}

	protected MainUI getMain() {
		return this.main;
	}

	protected boolean hasStopEntry(String platform) {
		boolean result = false;
		for (DecryptedTimeTableSingle single_plan : this) {
			if (single_plan.gleis.equals(platform))
				result = true;
		}
		return result;
	}
	
	protected DecryptedTimeTableSingle getStopEntry(String platform) {
		DecryptedTimeTableSingle result = null;
		for (DecryptedTimeTableSingle single_plan : this) {
			if (single_plan.gleis.equals(platform))
				result = single_plan;
		}
		return result;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		for (DecryptedTimeTableSingle table : this) {			
			result = prime * result + ((main == null) ? 0 : table.hashCode());
		}
		return result;
	}
	
	

}
